package interfaces;

import java.util.HashMap;
import java.util.Map;

import money.Money;
import banking.*;

public class BankRegistry{
	
	public static  Map<String, BankImpl> bankMap;
	private static BankRegistry theInstance;
	
	public BankRegistry() {
	
		BankRegistry.bankMap = new HashMap<String, BankImpl>();
	}
	
	public static BankRegistry getInstance()  {
        if (theInstance == null)
            theInstance = new BankRegistry();
        return theInstance;
    }
	
	
	public void newBank(String BankName){
		
		BankImpl Bank = new BankImpl(BankName);
		bankMap.put(BankName, Bank);
	}
	
	public static BankImpl loockup(String BankName){
		
		BankImpl Bank = bankMap.get(BankName);
		return Bank;
	}

	public static void B2Btransfer(int acceptorNumber,
			String accBankName, Money value, String reason) throws Exception{
		BankImpl acceptorBank = bankMap.get(accBankName);
		acceptorBank.addMoney(value, reason, acceptorNumber);
		
	}
}
